<?php

error_reporting(E_ERROR);
ini_set('display_errors', 'Off');
ini_set('log_errors', 'On');
ini_set('error_log', 'log/error.log');
header('content-type:text/html;charset=utf-8');

#Global Setup
$uid = false;
$user = array();
$news = array();
$theme = array();
$settings = array();

require_once ('config.php');
require_once (INC_PATH . '/function.php');
require_once (LIB_PATH . '/db.class.php');
require_once (LIB_PATH . '/cookie.class.php');
require_once (LIB_PATH . '/bbcode.class.php');
require_once (LIB_PATH . '/smarty/Smarty.class.php');

#Start The Execution Time
$startTime = slog_time();

#Mysql Connecter
$db = new DB(DB_HOST, DB_NAME, DB_USER, DB_PASS);

#Setup BBCode
$bbcode = new BBCode;

#Cookie Handle
$cookie = new cookieClass(COOKIE_NAME, COOKIE_TIME, true);

#Hard Load
loadSettings();
updateSession();
getUserId();
getUserProfile($uid);
getNews();
loadTheme();

#Shuffle The News
shuffle($news);

#Smarty Setup
$smarty = new Smarty();
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->cache_lifetime = 1800;
$smarty->assign('APP_URL', APP_URL);
$smarty->assign('uid', $uid);
$smarty->assign('user', $user);
$smarty->assign('theme', $theme);
$smarty->assign('setting', $settings);
$smarty->assign('news_json', json_encode($news));
$smarty->assign('nowTime', getStrTime(getTime(), false));
$smarty->assign('users_online', getUserOnline());
$smarty->assign('json_users_online', json_encode(getUserOnline()));

?>